import React, { Component } from 'react'

export default class HookTest extends Component {

  constructor () {
    super()
    // 初始化状态
    this.state = {
      msg: 'atguigu'
    }
  }

  render() { // 不能执行异步操作
    
    const {msg} = this.state
    return (
      <div style={{border: '1px solid gray'}}>
        <h3>LifeTest组件</h3>  
        <p>state.msg: {msg}</p>
        <p>props.count: {this.props.count}</p>

        <button onClick={this.handleClick}>更新msg</button>
        <button onClick={() => this.props.setCount(this.props.count + 2)}>更新父组件的count</button>
      </div>
    )
  }
}
